package com.sk.cardeal.act.home.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sk.cardeal.R;
import com.sk.cardeal.act.manage.fragment.InFragment;
import com.sk.cardeal.base.BaseActivity;
import com.sk.cardeal.dialog.TipDialogFragement;
import com.sk.cardeal.utils.MyUtils;
import com.sk.cardeal.utils.SPUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by sk on 2017/12/25.
 */

public class HomePageActivity extends BaseActivity {
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.commission_ll)
    RelativeLayout commissionLl;
    @BindView(R.id.sign_out)
    RelativeLayout signOut;
    @BindView(R.id.tv_version)
    TextView tvVersion;

    @Override
    protected int getContentView() {
        return R.layout.activity_home_page;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        tvName.setText(MyUtils.getUser(mContext).getPersonName());
        tvVersion.setText("当前版本："+MyUtils.getVersionName(mContext));
    }


    @OnClick({R.id.back, R.id.sign_out,R.id.change_pwd,R.id.my_wages,R.id.commission_ll})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.change_pwd:
                Intent pwIntent = new Intent(mContext,ChangePasswordActivity.class);
                startActivity(pwIntent);
                break;
            case R.id.my_wages:
                Intent wageIntent = new Intent(mContext,MyWagesActivity.class);
                startActivity(wageIntent);
                break;
            case R.id.commission_ll:
                Intent comissionIntent = new Intent(mContext,MyCommissionActivity.class);
                startActivity(comissionIntent);
                break;
            case R.id.back:
                finish();
                break;
            case R.id.sign_out:
                TipDialogFragement tipDialogFragement = new TipDialogFragement();
                tipDialogFragement.setMyCallBack(HomePageActivity.this);
                tipDialogFragement.setTipContent("是否确认退出当前登录?");
                tipDialogFragement.show(getSupportFragmentManager(), "tip");
                break;
        }
    }

    @Override
    public void sure() {
        super.sure();
        SPUtils.clear(mContext);
        setResult(RESULT_OK);
        finish();
    }
}
